package com.chinatechstar.decis.controller;

import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.chinatechstar.decis.entity.DecisMonthEffect;
import com.chinatechstar.decis.service.DecisMonthEffectService;
import com.chinatechstar.component.commons.result.ActionResult;
import com.chinatechstar.component.commons.result.ListResult;
import com.chinatechstar.component.commons.result.ResultBuilder;
import com.chinatechstar.component.commons.validator.InsertValidator;
import com.chinatechstar.component.commons.validator.UpdateValidator;

/**
 * 综合效果评价-单井注气吞吐实施效果月统计 的控制层
 *
 * @author Rei
 */
@Api(value = "综合效果评价-单井注气吞吐实施效果月统计 的控制层", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
@RestController
@RequestMapping("/decismontheffect")
public class DecisMonthEffectController {

    @Autowired
    private DecisMonthEffectService decisMonthEffectService;

    /**
     * 查询 综合效果评价-单井注气吞吐实施效果月统计 所有数据
     *
     * @return ListResult<Object>
     */
    @ApiOperation(value = "查询 综合效果评价-单井注气吞吐实施效果月统计 所有数据", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @GetMapping(path = "/findDecisMonthEffectAll")
    public ListResult<Object> findDecisMonthEffectAll() {
        List<DecisMonthEffect> list = decisMonthEffectService.findDecisMonthEffectAll();
        return ResultBuilder.buildListSuccess(list);
    }

    /**
     * 查询 综合效果评价-单井注气吞吐实施效果月统计 分页
     *
     * @param currentPage 当前页数
     * @param pageSize    每页记录数
     * @param name        名称
     * @param sorter      排序
     * @return ListResult<Object>
     */
    @ApiOperation(value = "查询 综合效果评价-单井注气吞吐实施效果月统计 分页", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @GetMapping(path = "/findDecisMonthEffectByCondition")
    public ListResult<Object> findDecisMonthEffectByCondition(@RequestParam(name = "currentPage", required = false, defaultValue = "1") Integer currentPage,
                                                              @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                                              @RequestParam(name = "name", required = false) String name,
                                                              @RequestParam(name = "sorter", required = false) String sorter) {
        Map<String, Object> data = decisMonthEffectService.findDecisMonthEffectByCondition(currentPage, pageSize, name, sorter);
        return ResultBuilder.buildListSuccess(data);
    }

    /**
     * 根据主键ID查询 综合效果评价-单井注气吞吐实施效果月统计 数据
     *
     * @param id ID
     * @return ActionResult
     */
    @ApiOperation(value = "根据主键ID数据查询 综合效果评价-单井注气吞吐实施效果月统计 数据", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @GetMapping(path = "/findDecisMonthEffectById")
    public ActionResult findDecisMonthEffectById(@RequestParam(name = "id") Long id) {
        DecisMonthEffect data = decisMonthEffectService.findDecisMonthEffectById(id);
        return ResultBuilder.buildActionSuccess(data);
    }

    /**
     * 根据主键ID数组查询 综合效果评价-单井注气吞吐实施效果月统计 数据
     *
     * @param ids ID数组
     * @return ActionResult
     */
    @ApiOperation(value = "根据主键ID数组查询 综合效果评价-单井注气吞吐实施效果月统计 数据", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @GetMapping(path = "/findDecisMonthEffectByIds")
    public ListResult<Object> findDecisMonthEffectByIds(@RequestParam(name = "ids") Long[] ids) {
        List<DecisMonthEffect> list = decisMonthEffectService.findDecisMonthEffectByIds(ids);
        return ResultBuilder.buildListSuccess(list);
    }

    /**
     * 新增 综合效果评价-单井注气吞吐实施效果月统计
     *
     * @param decisMonthEffect 综合效果评价-单井注气吞吐实施效果月统计 实体
     * @return ActionResult
     */
    @ApiOperation(value = "新增 综合效果评价-单井注气吞吐实施效果月统计", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @PostMapping(path = "/addDecisMonthEffect")
    public ActionResult addDecisMonthEffect(@Validated(InsertValidator.class) @RequestBody DecisMonthEffect decisMonthEffect) {
        decisMonthEffectService.insertDecisMonthEffect(decisMonthEffect);
        return ResultBuilder.buildActionSuccess();
    }

    /**
     * 批量新增 综合效果评价-单井注气吞吐实施效果月统计
     *
     * @param decisMonthEffects 综合效果评价-单井注气吞吐实施效果月统计 实体数组
     * @return ActionResult
     */
    @ApiOperation(value = "批量新增 综合效果评价-单井注气吞吐实施效果月统计", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @PostMapping(path = "/addDecisMonthEffects")
    public ActionResult addDecisMonthEffects(@Validated(InsertValidator.class) @RequestBody List<DecisMonthEffect> decisMonthEffects) {
        decisMonthEffectService.insertDecisMonthEffects(decisMonthEffects);
        return ResultBuilder.buildActionSuccess();
    }

    /**
     * 编辑 综合效果评价-单井注气吞吐实施效果月统计
     *
     * @param decisMonthEffect 综合效果评价-单井注气吞吐实施效果月统计 实体
     * @return ActionResult
     */
    @ApiOperation(value = "编辑 综合效果评价-单井注气吞吐实施效果月统计", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @PutMapping(path = "/updateDecisMonthEffect")
    public ActionResult updateDecisMonthEffect(@Validated(UpdateValidator.class) @RequestBody DecisMonthEffect decisMonthEffect) {
        decisMonthEffectService.updateDecisMonthEffect(decisMonthEffect);
        return ResultBuilder.buildActionSuccess();
    }

    /**
     * 批量编辑 综合效果评价-单井注气吞吐实施效果月统计
     *
     * @param decisMonthEffects 综合效果评价-单井注气吞吐实施效果月统计 实体数组
     * @return ActionResult
     */
    @ApiOperation(value = "批量编辑 综合效果评价-单井注气吞吐实施效果月统计", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @PostMapping(path = "/updateDecisMonthEffects")
    public ActionResult updateDecisMonthEffects(@Validated(UpdateValidator.class) @RequestBody List<DecisMonthEffect> decisMonthEffects) {
        decisMonthEffectService.updateDecisMonthEffects(decisMonthEffects);
        return ResultBuilder.buildActionSuccess();
    }

    /**
     * 删除 综合效果评价-单井注气吞吐实施效果月统计
     *
     * @param id ID
     * @return ActionResult
     */
    @ApiOperation(value = "根据主键ID删除 综合效果评价-单井注气吞吐实施效果月统计", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @PostMapping(path = "/deleteDecisMonthEffectById")
    public ActionResult deleteDecisMonthEffectById(@RequestParam(name = "id") Long id) {
        decisMonthEffectService.deleteDecisMonthEffectById(id);
        return ResultBuilder.buildActionSuccess();
    }

    /**
     * 删除 综合效果评价-单井注气吞吐实施效果月统计
     *
     * @param ids ID数组
     * @return ActionResult
     */
    @ApiOperation(value = "根据主键ID数组批量删除 综合效果评价-单井注气吞吐实施效果月统计", tags = {"综合效果评价-单井注气吞吐实施效果月统计"})
    @PostMapping(path = "/deleteDecisMonthEffectByIds")
    public ActionResult deleteDecisMonthEffectByIds(@RequestParam(name = "id") Long[] ids) {
        decisMonthEffectService.deleteDecisMonthEffectByIds(ids);
        return ResultBuilder.buildActionSuccess();
    }

}
